<script setup lang="ts">
defineOptions({
  name: "baseInfo"
});

import { ref, watch, inject } from "vue";
import { formatBaseInfo } from "../../../../utils";
import baseModel from "./baseModel.vue";

const title = ref<string>("基本信息");
const detailData = inject<any>("detailData", ref<any>(null));
const loading = inject<any>("loading", ref<boolean>(false));
const baseInfoArr = ref<Array<any>>([]);

const init = () => {
  baseInfoArr.value.splice(0);
  const arr = formatBaseInfo(detailData.value);
  baseInfoArr.value.push(...arr);
};

watch(loading, val => {
  if (!val) {
    init();
  }
});
</script>

<template>
  <baseModel :title="title" :dataInfo="baseInfoArr" />
</template>
